#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

template <template<typename> typename Cmp = greater, typename T>
vector<int> get_next_prev(vector<T> &arr, bool prev = false) {
  int n = arr.size();
  vector<int> res(n);
  stack<int> st;
  for (int i = prev ? 0 : n - 1; prev ? i < n : i >= 0; prev ? ++i : --i) {
    while (!st.empty() && !Cmp<T>()(arr[st.top()], arr[i])) st.pop();
    res[i] = st.empty() ? (prev ? -1 : n) : st.top();
    st.push(i);
  }
  return res;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  auto next_greater = get_next_prev<greater_equal>(a);
  auto prev_greater = get_next_prev(a, true);
  vector<long long> ans(n + 4);
  for (int i = 0; i < n; i ++) {
    int left = i - prev_greater[i] - 1;
    int right = next_greater[i] - i - 1;
    ans[1] += a[i];
    ans[left + 2] -= a[i];
    ans[right + 2] -= a[i];
    ans[left + right + 3] += a[i];
  }
  partial_sum(ans.begin(), ans.end(), ans.begin());
  partial_sum(ans.begin(), ans.end(), ans.begin());
  for (int i = 1; i <= n; i ++) cout << ans[i] << '\n';
}